package com.matace.keychain.core.logUtil;

public class LogUtil {
    public static final int VERBOSE = 1;
    public static final int DEBUG = 2;
    public static final int INFO = 3;
    public static final int WARN = 4;
    public static final int ERROR = 5;
    public static final int NOTHING = 6;
    public static int LEVEL = VERBOSE;

    private static String clsInfo() {
        StackTraceElement ste = new Throwable().getStackTrace()[2];
        String cls_name = ste.getClassName();
        cls_name = cls_name.substring(cls_name.lastIndexOf(".") + 1);
        return String.format("%s|method:%s|line:%s", cls_name, ste.getMethodName(), ste.getLineNumber());
    }
    public static void v(String tag, String msg) {
        if (LEVEL <= VERBOSE) {
            android.util.Log.v(tag, clsInfo() + "|" + msg);
        }
    }

    public static void d(String tag, String msg) {
        if (LEVEL <= DEBUG) {
            android.util.Log.d(tag, clsInfo() + "|" + msg);
        }
    }

    public static void i(String tag, String msg) {
        if (LEVEL <= INFO) {
            android.util.Log.i(tag, clsInfo() + "|" + msg);
        }
    }

    public static void w(String tag, String msg) {
        if (LEVEL <= WARN) {
            android.util.Log.w(tag, clsInfo() + "|" + msg);
        }
    }

    public static void e(String tag, String msg) {
        if (LEVEL <= ERROR) {
            android.util.Log.e(tag, clsInfo() + "|" + msg);
        }
    }
}
